﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace FrmHotel
{
    public partial class FrmDaSaoFj : Form
    {
        public FrmDaSaoFj()
        {
            InitializeComponent();
        }
        public int id;//接收主菜单的房间号 
        private void FrmDaSaoFj_Load(object sender, EventArgs e)
        {
            ShowSata();
        }
        public void ShowSata()
        {
            string sql = string.Format("select r.RmId,m.RoomName,m.RoomMoney from RoomInfo r,Room m where  r.RmRoom=m.RoomId and r.RmId={0}", id);
            SqlDataReader reader = DBHelper.SelectMore(sql);
            if (reader.Read())
            {
                this.label3.Text = reader["RmId"].ToString();
                this.labelClass.Text = reader["RoomName"].ToString();
                this.labelmoney.Text = reader["RoomMoney"].ToString();
            }
            reader.Close();
        }


        private void button2_Click_1(object sender, EventArgs e)
        {
            this.timer1.Enabled = true;
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            this.Close();
        }
        int i = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (i == 100)
            {
                this.timer1.Enabled = false;
                string sql = string.Format("update RoomInfo set RmState=1 where RmId={0}", id);
                int r = DBHelper.ExecuteUpdate(sql);
                if (r > 0)
                {
                    MessageBox.Show("打扫完毕！", "提示信息！");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("打扫失败！", "提示信息！");
                    return;
                }
                this.Close();
                return;
            }
            this.progressBar1.Value = i;
            i = i + 5;
        }
     
    }
}
